﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UnityMultiPlayerGameServer.Data
{
    internal class RoomData
    {
        /// <summary>
        /// 房间ID
        /// </summary>
        int roomID;

        /// <summary>
        /// 房间名
        /// </summary>
        string roomName;

        /// <summary>
        /// 当前房间容量
        /// </summary>
        private int roomCapacity;

        /// <summary>
        /// 当前房间人数
        /// </summary>
        private int userCount = 0;

        /// <summary>
        /// 当前房间准备就绪的人数
        /// </summary>
        private int preparedUser = 0;


        #region 属性
        public int UserCount { get => userCount; set => userCount = value; }
        public int RoomCapacity { get => roomCapacity; }
        /// <summary>
        /// 当前房间剩余空间
        /// </summary>
        public int RoomRemain { get => (roomCapacity - userCount); }
        public int RoomID { get => roomID; }
        public string RoomName { get => roomName;   }
        public int PreparedUser { get => preparedUser; set => preparedUser = value; }
        public bool isAllPlayerPrepared { get => preparedUser == userCount; }
        #endregion

        public RoomData(int roomID, string roomName, int roomCapacity = 2)
        {
            this.roomID = roomID;
            this.roomName = roomName;
            this.roomCapacity = roomCapacity;
            userCount = 1;
        }

        public override string ToString()
        {
            return roomID + "  " + roomName + "  capacity:" + roomCapacity + "  count:" + UserCount;
        }
        /// <summary>
        /// userCount + 1
        /// </summary>
        public void AddUserCountOnce()
        {
            ++userCount;
        }
    }
}
